import App from './App'
import store from './store'
// import  {add_group} from '../common/uniCloudApi.js'
	import  * as UniCloudApi from './common/uniCloudApi.js';
	import  * as publicApi from './common/publicApi.js';

// main.js
// import uviewPlus from 'uview-plus'

// #ifndef VUE3
import Vue from 'vue'
var userInfo = uni.getStorageSync('userInfo')
	var isLogin = userInfo.openId != null? true:false

Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.$adpid = "wx7da5a2c25fd4157c"
Vue.prototype.$uniCloudApi = UniCloudApi // 将其添加到Vue原型链
Vue.prototype.$userInfo = userInfo // 
Vue.prototype.$isLogin = isLogin // 
// Vue.use(uView);


Vue.prototype.$backgroundAudioData = {
	playing: false,
	playTime: 0,
	formatedPlayTime: '00:00:00'
}
App.mpType = 'app'
const app = new Vue({
	store,
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
    var idList = uni.getStorageSync('idList')
	var userInfo = uni.getStorageSync('userInfo')
	
	var isLogin = userInfo.openId != null? true:false
   app.use(store)
	app.config.globalProperties.$adpid = "wxfc2c37f898379a79"
	app.config.globalProperties.$uniCloudApi = UniCloudApi // 将其添加到Vue原型链
	app.config.globalProperties.$userInfo = userInfo// 将其添加到Vue原型链
	app.config.globalProperties.$isLogin = isLogin // 将其添加到Vue原型链
	app.config.globalProperties.$publicApi = publicApi // 将其添加到Vue原型链
	app.config.globalProperties.$idList = idList //
	app.config.globalProperties.$userInfo = userInfo //
	app.config.globalProperties.$openAd = "1" //是否打开视频广告
	app.config.globalProperties.$videoAdId = "" //是否打开视频广告
	
	
	
	
	app.config.globalProperties.$backgroundAudioData = {
		playing: false,
		playTime: 0,
		formatedPlayTime: '00:00:00'
	}
	app.config.globalProperties.$setIdList = function(idList) {
		app.config.globalProperties.$idList = idList;
		console.log('idList====',app.config.globalProperties.$idList);
		
	};
	
	app.config.globalProperties.$setUserInfo = function(userData) {
		app.config.globalProperties.$userInfo = null;
	    app.config.globalProperties.$userInfo = userData;
		app.config.globalProperties.$isLogin = true;
		console.log('设置登录数据22====',app.config.globalProperties.$userInfo);
		console.log('设置登录数据33====',userData);
		
	};
	app.config.globalProperties.$removeUserInfo = function() {
		console.log('删除登录数据====');
	    app.config.globalProperties.$userInfo = null;
		app.config.globalProperties.$isLogin = false;
		
		console.log('删除登录数据22====',app.config.globalProperties.$userInfo);
	};
	app.config.globalProperties.$encodeJson = function(json) {
	  return	encodeURIComponent(JSON.stringify(json));
	};
	app.config.globalProperties.$decodeJson = function(jsonStr) {
	  return	JSON.parse(decodeURIComponent(jsonStr));
	};
	app.config.globalProperties.$setOpenAd = function(value) {
	  app.config.globalProperties.$openAd = value;
	  console.log('设置是否打开广告====',app.config.globalProperties.$openAd);
	};
	
	app.config.globalProperties.$setVideoAdId = function(value) {
	  app.config.globalProperties.$videoAdId = value;
	  console.log('设置广告id====',app.config.globalProperties.$videoAdId);
	};
	app.config.globalProperties.$showToast = function(text) {
	  uni.showToast({
	  	title:text,
		icon: 'none'
	  })
	};
	
	
	return {
		app
	}
}
// #endif
